<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE DefaultSignatures #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE MagicHash #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Unsafe.Shift</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   : (c) Bryan O'Sullivan 2009</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- /Warning/: this is an internal module, and does not have a stable</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- API or name. Functions in this module may not check or enforce</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- preconditions expected by public modules. Use at your own risk!</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- Fast, unchecked bit shifting functions.</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Unsafe.Shift</span><span>
</span><span id="line-21"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-22"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier">UnsafeShift</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Bits</span></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- | This is a workaround for poor optimisation in GHC 6.8.2.  It</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- fails to notice constant-width shifts, and adds a test and branch</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- to every shift.  This imposes about a 10% performance hit.</span><span>
</span><span id="line-31"></span><span class="hs-comment">--</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- These functions are undefined when the amount being shifted by is</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- greater than the size in bits of a machine Int#.</span><span>
</span><span id="line-34"></span><span class="hs-keyword">class</span><span> </span><span id="UnsafeShift"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier hs-var">UnsafeShift</span></a></span></span><span> </span><span id="local-6989586621679104576"><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-35"></span><span>    </span><span id="shiftL"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftL"><span class="hs-identifier hs-type">shiftL</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftL"><span class="hs-pragma hs-type">shiftL</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-keyword">default</span><span> </span><span id="shiftL"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftL"><span class="hs-identifier hs-type">shiftL</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#Bits"><span class="hs-identifier hs-type">Bits.Bits</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-38"></span><span>    </span><span id="local-6989586621679104548"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftL"><span class="hs-identifier hs-var hs-var">shiftL</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Int -&gt; a
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#unsafeShiftL"><span class="hs-identifier hs-var">Bits.unsafeShiftL</span></a></span></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>    </span><span id="shiftR"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-identifier hs-type">shiftR</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-pragma hs-type">shiftR</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-keyword">default</span><span> </span><span id="shiftR"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-identifier hs-type">shiftR</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#Bits"><span class="hs-identifier hs-type">Bits.Bits</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104576"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-43"></span><span>    </span><span id="local-6989586621679104543"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-identifier hs-var hs-var">shiftR</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Int -&gt; a
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="../../base/src/Data.Bits.html#unsafeShiftR"><span class="hs-identifier hs-var">Bits.unsafeShiftR</span></a></span></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104536"><span id="local-6989586621679104538"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier hs-type">UnsafeShift</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-46"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104531"><span id="local-6989586621679104533"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier hs-type">UnsafeShift</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-47"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104527"><span id="local-6989586621679104529"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier hs-type">UnsafeShift</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-48"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104523"><span id="local-6989586621679104525"><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#UnsafeShift"><span class="hs-identifier hs-type">UnsafeShift</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-49"></span></pre></body></html>